﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_DanhMuc.AccessDatabase
{
    class DanhMucNhomVT
    {
        AccessData ac = new AccessData(1);
        public int them(string tennhom)
        {
            SqlParameter[] arrpara = new SqlParameter[1];
            arrpara[0]=new SqlParameter("TenNhomVT",SqlDbType.NVarChar);
            arrpara[0].Value = tennhom;
            DataTable dt = ac.ftblDocDuLieuSP("sp_themnhomvt", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int sua(int manhom,string tennhom)
        {
            SqlParameter[] arrpara = new SqlParameter[2];
            arrpara[0] = new SqlParameter("MaNhomVT", SqlDbType.Int);
            arrpara[1] = new SqlParameter("TenNhomVT", SqlDbType.NVarChar);
            arrpara[0].Value = manhom;
            arrpara[1].Value = tennhom;
            DataTable dt = ac.ftblDocDuLieuSP("sp_suanhomvt", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoa(int manhom)
        {
            SqlParameter[] arrpara = new SqlParameter[1];
            arrpara[0] = new SqlParameter("MaNhomVT", SqlDbType.Int);
            arrpara[0].Value = manhom;
            DataTable dt = ac.ftblDocDuLieuSP("sp_xoanhomvt", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable load_grid()
        {
            return ac.ftblDocDuLieuSP("sp_loadnhomvt", null);
        }
    }
}
